unit frmModifyRoom;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, uDelphiBaseForm, uLangConst;

type
  TRoomItem = class
  public
    Name: string;
    IP: string;
    function Empty(): Boolean;
  end;
  
  TModifyRoomForm = class(TDelphiBaseForm)
    btnOK: TButton;
    btnCancel: TButton;
    GroupBox1: TGroupBox;
    txtName: TStaticText;
    edtRoomName: TEdit;
    StaticText1: TStaticText;
    edtRoomIP: TEdit;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    procedure ChangeLanguage(ALanguageIniFile: string); override;
  end;

var
  ModifyRoomForm: TModifyRoomForm;

function ModifyRoomItem(ARoomItem: TRoomItem): Boolean;

implementation

{$R *.dfm}

function ModifyRoomItem(ARoomItem: TRoomItem): Boolean;
begin
  Result := False;
  ModifyRoomForm := TModifyRoomForm.Create(nil);
  try
    if ARoomItem <> nil then
    begin
      ModifyRoomForm.edtRoomName.Text := ARoomItem.Name;
      ModifyRoomForm.edtRoomIP.Text := ARoomItem.IP;
    end;
    
    if ModifyRoomForm.ShowModal = 1 then
    begin
      ARoomItem.Name := ModifyRoomForm.edtRoomName.Text;
      ARoomItem.IP := ModifyRoomForm.edtRoomIP.Text;
      Result := True;
    end;
  finally
    ModifyRoomForm.Free;
  end;
end;

{ TRoomItem }

function TRoomItem.Empty: Boolean;
begin
  if (Length(Name) > 0) and (Length(IP) > 8) then
    Result := False
  else
    Result := True;
end;

{ TModifyRoomForm }

procedure TModifyRoomForm.ChangeLanguage(ALanguageIniFile: string);
begin
  inherited ChangeLanguage(ALanguageIniFile);
end;

procedure TModifyRoomForm.FormShow(Sender: TObject);
begin
  TranslateConsts(getLanguageFileName());
  ChangeLanguage(getLanguageFileName());
end;

end.
